classdef MultiLabelMacroF1Measure ...
        < MultiLabelMetric
    %MULTILABELMACROF1MEASURE Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
    end
    
    methods
        function [ this ] = MultiLabelMacroF1Measure( name )
            if nargin == 0
                this.setName('mlabel_macro_f1');
            end
            if nargin >= 1
                this.setName(name);
            end
        end
    end
    
    methods
        function [ result ] = apply( this, Y, Y_hat, Y_out )
            result = MultiLabelMacroF1Measure.calc(Y, Y_hat);
        end
    end
    
    methods ( Static = true )
        function [ result ] = calc( Y, Y_hat, Y_out )
            Y(Y == -1) = 0;
            Y_hat(Y_hat == -1) = 0;
            result = 2*sum(Y.*Y_hat, 1)./(sum(Y, 1) + sum(Y_hat, 1));
            result(isnan(result)) = [];
            result = mean(result, 2);
        end
    end
    
end

